package org.xiaodongwei.jvm.op;

import org.xiaodongwei.jvm.exe.JVMStack;
import tech.medivh.classpy.classfile.bytecode.Instruction;
import tech.medivh.classpy.classfile.constant.ConstantPool;
import tech.medivh.classpy.classfile.jvm.Opcode;

public class FConstOpCodeExecute extends OpCodeExecute {

    public FConstOpCodeExecute(Opcode opcode, JVMStack jvmStack, ConstantPool constantPool) {
        this.opCode = opcode;
        this.jvmStack = jvmStack;
        this.constantPool = constantPool;
    }

    @Override
    public void execute(Instruction instruction) {
        switch (this.opCode) {
            case fconst_0 -> {
                jvmStack.peek().getOperateStack().push(0.0f);
            }
            case fconst_1 -> {
                jvmStack.peek().getOperateStack().push(1.0f);
            }
            case fconst_2 -> {
                jvmStack.peek().getOperateStack().push(2.0f);
            }
            default -> {

            }
        }
    }
}
